package com.health.tablebean.webservice;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.health.NovaApplication;
import com.health.db.FDbManager;
import com.health.tablebean.OLDER_SELFCAREABILITY;
import com.health.tools.GlobalConts;

import android.content.Context;
import android.text.TextUtils;

/**
 * @author Administrator 老年人生活自理能力
 */
public class OldSelfHelp {
	private String activity;// 活动站立、室内行走、上下楼梯、户外活动
	private String cleanUp;// 梳洗梳头、洗脸、刷牙、剃须洗澡等活动
	private String createorg;// 创建机构
	private String creater;// 创建人
	private String createtime;// 创建时间
	private String dress;// 穿衣穿衣裤、袜子、鞋子等活动
	private String happentime;// 建档时间
	private String meal;// 进餐使用餐具将饭菜送入口、咀嚼、吞咽等活动
	private String modified;// 修改人
	private String toilet;// 如厕小便、大便等活动及自控
	private String totalpoint;// 总计
	private String updateorg;// 更新机构
	private String updatetime;// 更新时间
	private String cardid;// 居民身份证/健康卡号
	private String fromType = "2";// 数据来源 空为公卫，'1'为手提箱，'2'为PAD。

	public String getFromType() {
		return fromType;
	}

	public void setFromType(String fromType) {
		this.fromType = fromType;
	}

	public String getActivity() {
		return activity;
	}

	public void setActivity(String activity) {
		this.activity = activity;
	}

	public String getCleanUp() {
		return cleanUp;
	}

	public void setCleanUp(String cleanUp) {
		this.cleanUp = cleanUp;
	}

	public String getCreateorg() {
		return createorg;
	}

	public void setCreateorg(String createorg) {
		this.createorg = createorg;
	}

	public String getCreater() {
		return creater;
	}

	public void setCreater(String creater) {
		this.creater = creater;
	}

	public String getCreatetime() {
		return createtime;
	}

	public void setCreatetime(String createtime) {
		this.createtime = createtime;
	}

	public String getDress() {
		return dress;
	}

	public void setDress(String dress) {
		this.dress = dress;
	}

	public String getHappentime() {
		return happentime;
	}

	public void setHappentime(String happentime) {
		this.happentime = happentime;
	}

	public String getMeal() {
		return meal;
	}

	public void setMeal(String meal) {
		this.meal = meal;
	}

	public String getModified() {
		return modified;
	}

	public void setModified(String modified) {
		this.modified = modified;
	}

	public String getToilet() {
		return toilet;
	}

	public void setToilet(String toilet) {
		this.toilet = toilet;
	}

	public String getTotalpoint() {
		return totalpoint;
	}

	public void setTotalpoint(String totalpoint) {
		this.totalpoint = totalpoint;
	}

	public String getUpdateorg() {
		return updateorg;
	}

	public void setUpdateorg(String updateorg) {
		this.updateorg = updateorg;
	}

	public String getUpdatetime() {
		return updatetime;
	}

	public void setUpdatetime(String updatetime) {
		this.updatetime = updatetime;
	}

	public String getCardid() {
		return cardid;
	}

	public void setCardid(String cardid) {
		this.cardid = cardid;
	}

	public static List<OldSelfHelp> convertData(Context context) {
		List<OldSelfHelp> datas = new ArrayList<>();
		FDbManager fdb = FDbManager.getInstance(context);
		List<OLDER_SELFCAREABILITY> olds = fdb.findAllByWhere(OLDER_SELFCAREABILITY.class,"IS_UPDATE='" + "Y' AND CREATER='" + NovaApplication.getJgrno() + "'");
//		List<OLDER_SELFCAREABILITY> olds = fdb.findAll(OLDER_SELFCAREABILITY.class);
		OldSelfHelp oldself = null;
		for (OLDER_SELFCAREABILITY old : olds) {
			oldself = new OldSelfHelp();
			oldself.setActivity(old.getACTIVITY());// 活动站立、室内行走、上下楼梯、户外活动
			oldself.setCreateorg(old.getCREATEORG());// 创建机构
			oldself.setCreater(old.getCREATED_BY());// 创建人
			oldself.setCreatetime(GlobalConts.datetimeFormat.format(new Date()));// 创建时间
			oldself.setHappentime(
					old.getCREATED_DATE() == null ? "" : GlobalConts.datetimeFormat.format(old.getCREATED_DATE()));// 建档时间

			// oldself.setMeal(old.getDINE());// 进餐使用餐具将饭菜送入口、咀嚼、吞咽等活动
			// oldself.setCleanUp(old.getGROMING());// 梳洗梳头、洗脸、刷牙、剃须洗澡等活动
			// oldself.setDress(old.getDRESSING());// 穿衣穿衣裤、袜子、鞋子等活动
			// oldself.setToilet(old.getTOLET());// 如厕小便、大便等活动及自控

			if (!TextUtils.isEmpty(old.getDINE())) {// 进餐使用餐具将饭菜送入口、咀嚼、吞咽等活动
				switch (old.getDINE()) {
				case "0":
					oldself.setMeal("0");
					break;
				case "1":
					oldself.setMeal("2");
					break;
				case "2":
					oldself.setMeal("3");
					break;
				case "3":
					oldself.setMeal("5");
					break;
				default:
					break;
				}
			} else {

			}
			if (!TextUtils.isEmpty(old.getGROMING())) {
				// 梳洗梳头、洗脸、刷牙、剃须洗澡等活动
				switch (old.getGROMING()) {
				case "0":
					oldself.setCleanUp("0");
					break;
				case "1":
					oldself.setCleanUp("1");
					break;
				case "2":
					oldself.setCleanUp("3");
					break;
				case "3":
					oldself.setCleanUp("7");
					break;
				default:
					break;
				}
			}
			if (!TextUtils.isEmpty(old.getDRESSING())) {
				// 穿衣穿衣裤、袜子、鞋子等活动
				switch (old.getDRESSING()) {
				case "0":
					oldself.setDress("0");
					break;
				case "1":
					oldself.setDress("2");
					break;
				case "2":
					oldself.setDress("3");
					break;
				case "3":
					oldself.setDress("5");
					break;
				default:
					break;
				}
			}
			if (!TextUtils.isEmpty(old.getTOLET())) {
				// 如厕小便、大便等活动及自控
				switch (old.getTOLET()) {
				case "0":
					oldself.setToilet("0");
					break;
				case "1":
					oldself.setToilet("1");
					break;
				case "2":
					oldself.setToilet("5");
					break;
				case "3":
					oldself.setToilet("10");
					break;
				default:
					break;
				}
			}

			if (!TextUtils.isEmpty(old.getACTIVITY())) {
				// 如厕小便、大便等活动及自控
				switch (old.getACTIVITY()) {
					case "0":
						oldself.setActivity("0");
						break;
					case "1":
						oldself.setActivity("1");
						break;
					case "2":
						oldself.setActivity("5");
						break;
					case "3":
						oldself.setActivity("10");
						break;
					default:
						break;
				}
			}
			oldself.setTotalpoint(old.getTOTALSCORE());// 总计
			oldself.setModified(old.getLAST_UPDATE_BY());// 修改人
			oldself.setUpdateorg(old.getUPDATEORG());// 更新机构
			oldself.setUpdatetime(old.getLAST_UPDATE_DATE() == null ? ""
					: GlobalConts.datetimeFormat.format(old.getLAST_UPDATE_DATE()));// 更新时间
			oldself.setCardid(old.getIDCARD());// 居民身份证/健康卡号
			oldself.setFromType("2");
			datas.add(oldself);
		}

		return datas;
	}

}
